<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.server.web.JsVersionUtil"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title>消息推送表单</title>
<script type="text/javascript"
	src='<c:url value="/js/boot.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<script src='<c:url value="/js/rqfui/rqfui.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/share/styles.css"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>' />
<style type="text/css">
body {
	height: 100%;
}

.fieldTitle {
	width: 80px !important;
}

.mini-tabs-leftButton, .mini-tabs-rightButton {
	display: none;
}

.mini-tabs-scrollCt {
	border-top: 0;
}

.mini-tabs-bodys {
	padding: 0;
}
.headerpan{
	margin-left: 10px;
	font-size: 14px;
	font-weight:bold;
}
</style>
<script type="text/javascript">
	var halfDayData = [{'text':'上午'},{'text':'下午'}];
</script>
</head>
<body>
	<form id="dataForm">
		<div class="formContent">
			<input id="luuids" name="luuids" class="mini-hidden"
				style="width: 100%;" />
			<input id="lphoneNos" name="lphoneNos" class="mini-hidden"
				style="width: 100%;" />
			<input id="tphoneNos" name="tphoneNos" class="mini-hidden"
				style="width: 100%;" />
			<input id="tuuids" name="tuuids" class="mini-hidden"
				style="width: 100%;" />
			<input id="leuuids" name="leuuids" class="mini-hidden"
				style="width: 100%;" />
			<input id="lephoneNos" name="lephoneNos" class="mini-hidden"
				style="width: 100%;" />
				<input id="fuuids" name="fuuids" class="mini-hidden"
				style="width: 100%;" />
			<input id="fphoneNos" name="fphoneNos" class="mini-hidden"
				style="width: 100%;" />
			<table class="formContentTable">
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
				<tr>
					<td class="fieldTitle">调度名称</td>
					<td class="fieldContent" colspan="3"><input id="name"
						required="true" name="name" class="mini-textbox"
						style="width: 100%;" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">培训/会议主题</td>
					<td class="fieldContent" colspan="3"><input id="title"
						required="true" name="title" class="mini-textbox"
						style="width: 100%;" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">时间安排</td>
					<td class="fieldContent" colspan="2"><input id="time1" name="time1"
						class="mini-datepicker" required="true" style="width: 100%;" onvaluechanged="selectTime();" /></td>
					<td class="fieldContent" colspan="1">
						<input id="time2" name="time2" style="width: 100%;"
							textField="text" valueField="text" data="halfDayData"
							required="true" class="mini-combobox" onvaluechanged="selectHalf();" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">参训/会议人员</td>
					<td class="fieldContent" colspan="3"><a
						href="javascript:addUsers(1)"><textarea id="trainees" name="trainees"
						style="width: 100%; height: 100px;" required="true" allowinput="false"
						class="mini-textarea" emptyText="无"></textarea></a></td>
				</tr>
				<tr>
					<td class="fieldTitle">参与领导</td>
					<td class="fieldContent" colspan="3"><a
						href="javascript:addUsers(2)"><textarea id="leaders" name="leaders"
						style="width: 100%; height: 100px;" required="true" allowinput="false"
						class="mini-textarea" emptyText="无"></textarea></a></td>
				</tr>
				<tr>
					<td class="fieldTitle">师资人员选择</td>
					<td class="fieldContent" colspan="3"><a
						href="javascript:addUsers(3)"><textarea id="lecturers" name="lecturers"
						style="width: 100%; height: 100px;" required="true" allowinput="false"
						class="mini-textarea" emptyText="无"></textarea></a></td>
				</tr>
				<tr>
					<td class="fieldTitle">场地选择</td>
					<td class="fieldContent" colspan="3"><a
						href="javascript:addUsers(4)"><textarea id="field" name="field"
						style="width: 100%; height: 100px;" required="true" allowinput="false"
						class="mini-textarea" emptyText="无"></textarea></a></td>
				</tr>
				<tr>
					<td class="fieldTitle">编制人</td>
					<td class="fieldContent"><input id="creater" enabled="false"
						name="creater" class="mini-textbox" style="width: 100%;"
						value="${creater}" /></td>
					<td class="fieldTitle">编制日期</td>
					<td class="fieldContent"><input id="createTime" enabled="false"
						name="createTime" class="mini-datepicker" style="width: 100%;"
						value="${createTime}" /></td>
				</tr>
			</table>
		</div>
	</form>

	<script type="text/javascript">
		mini.parse();
		mini_debugger = false;
		var rootPath = parent.getRootPath();
		var userName = parent.getUserName();
		var action = parent.getAction();
		var uuid = parent.getUuid();
		var onlyCheck = parent.onlyCheck;
		var dataOri = null;
		var time1 = null;
		var time2 = null;
		var id = parent.getId();
		var userData = null;
		var leaders = mini.get("leaders");
		var trainees = mini.get("trainees");
		var lecturers = mini.get("lecturers");
		var field = mini.get("field");
		var luuids = mini.get("luuids");
		var leuuids = mini.get("leuuids");
		var tuuids = mini.get("tuuids");
		var fuuids = mini.get("fuuids")
		var lphoneNos = mini.get("lphoneNos");
		var lephoneNos = mini.get("lephoneNos");
		var tphoneNos = mini.get("tphoneNos");
		var fphoneNos = mini.get("fphoneNos");
	
		

		var form = new mini.Form("dataForm");
		
		if(parent.hideAtt){
			parent.hideAtt();
		}
		
		SetFormData();
		
		function SetFormData() {
			if(action == "new"){
				var o = new Object();
				o.creater = userName;
				o.pushType = '0';
				o.type = '自定义';
				o.createTime = new Date();
				form.setData(o);
				dataOri = o;
				//pushTime.disable();
				return;
			}
			var messageid = mini.loading("获取中...", "Loading");
			var urlBase = '<c:url value="/dispatch/form/"></c:url>'+ id;
			$.ajax({
				url : urlBase,
				type : "get",
				dataType : 'json',
				success : function(text) {
					if (!text) {
						return;
					}
					var o = mini.decode(text);
					var time = o.time;
					o.time1 = time.substr(0,10);
					o.time2 = time.substr(10);
					form.setData(o);
					dataOri = o;
					parent.labelModel(form);
				},
				complete : function(XMLHttpRequest, textStatus) {
					mini.hideMessageBox(messageid);
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {

				}
			});
		}
		function packData() {
			return form;
		}
		function addUsers(type){
			var url = null;
			var title = null;
			console.log(type);
			switch(type){
			case 1:
				url='<c:url value="/userMng/2"></c:url>';
				break;
			case 2:
				url='<c:url value="/adminUser/2"></c:url>';
				break;
			case 3:
				if(time1 && time2){
					url='<c:url value="/lecturer/2?time="></c:url>'+time1+","+time2;
				}else{
					top.commonTools.showTip("请选择时间安排！", 2);
				}
				break;
			case 4:
				if(time1 && time2){
					url='<c:url value="/field?time="></c:url>'+time1+","+time2;
				}else{
					top.commonTools.showTip("请选择时间安排！", 2);
				}
				break;
				
			}
			switch(type){
			case 1:
				title='添加参训/会议人员';
				break;
			case 2:
				title='添加参与领导';
				break;
			case 3:
				title='添加师资人员';
				break;
			case 4:
				title='添加场地';
				break;
			}

			if(action == "check" || onlyCheck){
				return;
			}
			if(url){
			mini.open({
				url : url,
				title : title,
				width : 800,
				height : 600,
				ondestroy : function(action) {
					if(action == "ok"){
						userData = this.getIFrameEl().contentWindow.data;
						switch(type){
						case 1:
							trainees.setValue(userData.names);
							tuuids.setValue(userData.uuids);
							tphoneNos.setValue(userData.phoneNos);
							break;
						case 2:
							leaders.setValue(userData.names);
							luuids.setValue(userData.uuids);
							lphoneNos.setValue(userData.phoneNos);
							break;
						case 3:
							lecturers.setValue(userData.names);
							leuuids.setValue(userData.uuids);
							lephoneNos.setValue(userData.phoneNos);
							break;
						case 4:
							field.setValue(userData.names);
							fuuids.setValue(userData.uuids);
							fphoneNos.setValue(userData.phoneNos);
							break;
						default:
							break;
						}
						top.commonTools.showTip("添加成功！", 1);
					}
				}
			});
			}
		}
		function selectTime(){
			time1 = mini.get("time1").getValue();
			if(mini.get("time2").getValue()){
				time2 = mini.get("time2").getValue();
			}
			time1 = new Date(time1);
		 	time1 = time1.valueOf();
		 	if(action=="edit"){
		 		lecturers.setValue();
				leuuids.setValue();
				lephoneNos.setValue();
				field.setValue();
				fuuids.setValue();
				fphoneNos.setValue();
		 	}

		}
		function selectHalf(){
			time1 = mini.get("time1").getValue();
			time2 = mini.get("time2").getValue();
			if(!time1){
				top.commonTools.showTip("请选择日期！", 2);
			}
			time1 = new Date(time1);
			time1 = time1.valueOf();
			
			if(action=="edit"){
		 		lecturers.setValue();
				leuuids.setValue();
				lephoneNos.setValue();
				field.setValue();
				fuuids.setValue();
				fphoneNos.setValue();
		 	}
		}
	</script>
</body>
</html>